<?php
ini_set("display_errors", "On");
error_reporting(E_ALL);

interface Shape {
    function area();
    function girth();
    function window();
    function verity($array);
}

class Rect implements Shape {
    public $width;
    public $height;
    public $name;


        function __construct($array=array()) {

                if(!empty($array)) {
                    $this -> width = $array['width'];
                    $this -> height = $array['height'];
                }
                 $this -> name = "矩形";
            }

        function area() {
            return $this->width*$this->height;
        }
        function girth() {
            return 2*($this->width+$this->height);
        }
        function window() {
            $form = '<form action="main.php?action=rect" method="post">';
            $form .= $this -> name.'的宽是：<input type="text" name="width" value="'.$this -> width.'" /><br />';
            $form .= $this -> name.'的长是：<input type="text" name="height" value="'.$this -> height.' "/><br />';
            $form .= '<input type="submit" name="dosubmit" value="计算"/><br />';
            $form .= '</form>';
            echo $form;
        }
        function verity($array) {
            $flag = true;
    		if(!$array['width'] || $array['width'] < 0) {
    			echo $this->name."的宽不能小于0!<br>";
    			$flag = false;
    		}

    		if(!$array['height'] ||$array['height'] < 0) {
    			echo $this->name."的高度不能小于0!<br>";
    			$flag = false;
    		}

    		return $flag;
        }
}
